package com.changgou.goods.dao;

import com.changgou.goods.pojo.Spec;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
import java.util.Map;

public interface SpecMapper extends Mapper<Spec> {

    /**
     * 根据商品分类查询商品规格信息
     *
     * @param categoryName
     * @return java.util.List<java.util.Map>
     * @throws
     * @description
     * @author kfzhao
     * @date 2021/12/25 1:27
     */
    @Select("select name, options\n" +
            "from tb_spec\n" +
            "where template_id in (\n" +
            "    select template_id\n" +
            "    from tb_category\n" +
            "    where name = #{categoryName}\n" +
            ")")
    public List<Map> findSpecListByCategoryName(@Param("categoryName") String categoryName);
}
